
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */

/*
* TileButton.java
*
* Created on Feb 18, 2010, 1:16:23 PM
 */
package meeple;

//~--- JDK imports ------------------------------------------------------------

import java.awt.*;
import java.awt.image.BufferedImage;

/**
 *
 * @author rogier
 */
public class TileButton extends javax.swing.JPanel {
    BufferedImage image;

    /** Creates new form TileButton */
    public TileButton() {
        initComponents();
        image = null;
    }

    public void Setimage(BufferedImage img) {
        image = img;
        repaint();
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        setPreferredSize(new java.awt.Dimension(50, 50));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);

        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
                Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
                Short.MAX_VALUE));
    }                                                             // </editor-fold>//GEN-END:initComponents

    private void formKeyPressed(java.awt.event.KeyEvent evt) {    // GEN-FIRST:event_formKeyPressed

        // TODO add your handling code here:
    }                                                                 // GEN-LAST:event_formKeyPressed

    private void formMouseClicked(java.awt.event.MouseEvent evt) {    // GEN-FIRST:event_formMouseClicked

        // TODO add your handling code here:
    }    // GEN-LAST:event_formMouseClicked

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponents(g);

        if (image != null) {
            g.drawImage(image, 0, 0, this);
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}


//~ Formatted by Jindent --- http://www.jindent.com
